<template>
  <el-dialog title="状态管理" :visible.sync="isStateManagement" width="50%" :before-close="handleClose" :close-on-click-modal='false'>
    <el-form ref="form" :model="form" label-width="85px" label-position="left" size="small">
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="姓名：">
            {{this.row.real_name}}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="性别：">
            {{this.row.sex}}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="学段：">
            {{this.row.section_title}}
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="年级：">
            {{this.row.grade_title}}
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="班级：">
            {{this.row.class_title}}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="24">
          <el-form-item label="预警方式：">
            {{this.row.mode}}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="24">
          <el-form-item label="危机类型：">
            {{this.row.type_title}}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="24">
          <el-form-item label="危机管理：">
            <el-select v-model="form.status" clearable placeholder="请选择">
              <el-option v-for="item in selectList" :key="item.id" :label="item.title" :value="item.id"> </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="24">
          <el-form-item label="备注说明：">
            <el-input type="textarea" :rows="4" placeholder="请输入内容" v-model="form.notes"> </el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="close()">取 消</el-button>
      <el-button type="primary" @click="checkFn()">确 定</el-button>
    </span>
  </el-dialog>
</template>
<script>
import {APICRISISGETSUNDRY, APICRISISSTATUSMANAGE} from '@/common/api.js'
export default {
  props: ['isStateManagement', 'row'],
  data () {
    return {
      form: {
        status: '',
        notes: ''
      },
      selectList: []
    }
  },
  created () {
    this.selectFn()
    this.form.status = this.row.status_title
  },
  methods: {
    handleClose () {
      this.$emit('noStateManagement')
    },
    close (type) {
      this.$emit('noStateManagement', type)
    },
    selectFn () {
      APICRISISGETSUNDRY().then((res) => {
        this.selectList = res.data.status_list
      }).catch((err) => {
        this.$message.error(err.msg)
      })
    },
    checkFn () {
      this.form.crisis_id = this.row.id
      APICRISISSTATUSMANAGE(this.form).then((res) => {
        this.close(1)
      }).catch((err) => {
        this.$message.error(err.msg)
      })
    }
  }
}
</script>
